#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<cstring>
using namespace std;
const int N = 1010;
int a[N][N];
int dp[N][N];
int main()
{
    int r;
    cin >> r;
    memset(dp, -0x3f3f3f3f, sizeof(dp));
    dp[0][0] = 0;
    dp[0][1] = 0;
    for (int i = 1; i <= r; i++)
    {
        for (int j = 1; j <= i; j++)
        {
            cin >> a[i][j];
        }
    }
    for (int i = 1; i <= r; i++)
    {
        for (int j = 1; j <= r; j++)
        {
            dp[i][j] = max(dp[i - 1][j - 1], dp[i - 1][j]) + a[i][j];
        }
    }
    int ret = 0;
    for (int i = 1; i <= r; i++)
    {
        ret = max(ret, dp[r][i]);
    }
    cout << ret << endl;
    return 0;
}